package com.keon.jianbao.ui.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import com.keon.jianbao.adapter.JianBaoListAdapter;
import com.keon.jianbao.api.Api;
import com.keon.jianbao.base.BaseActivity;
import com.keon.jianbao.base.BaseListAdapter;
import com.keon.jianbao.base.BaseListFragment;
import com.keon.jianbao.bean.JianBaoList;
import com.keon.jianbao.bean.ListAppraisal;
import com.keon.jianbao.bean.ListEntity;
import com.keon.jianbao.ui.activity.AppraisalDetailActivity;

/**
 * Created by keon on 2015/9/9.
 */
public class JianBaoListFragment extends BaseListFragment {

    int mSize = 10;

    @Override
    protected void sendRequestData() {
        Api.appraisal_lists(mCatalog, mCurrentPage, mSize, mHandler);
    }

    @Override
    protected ListEntity parseList(String reponseData) {

        JianBaoList jianBaoList = new JianBaoList(reponseData);

        return jianBaoList;
    }

    @Override
    protected BaseListAdapter getListAdapter() {
        return new JianBaoListAdapter();
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View view) {

    }

    @Override
    public void initView(View view) {
        super.initView(view);
        mListView.setDividerHeight(20);
    }

    @Override
    protected int getPageSize() {
        return mSize;
    }

    @Override
    protected String getCacheKeyPrefix() {
        return "JIANBAOLIST";
    }

    @Override
    public void onItemClick(AdapterView parent, View view, int position, long id) {

        if (position < mAdapter.getData().size()) {
            ListAppraisal listAppraisal = (ListAppraisal) mAdapter.getData().get(position);
            Bundle bundle = new Bundle();
            bundle.putInt("id", listAppraisal.getId());
            BaseActivity ba = (BaseActivity) getActivity();
            ba.jump(AppraisalDetailActivity.class, bundle);
        }
        
    }

    @Override
    protected boolean onTimeRefresh() {
        return true;
    }
}
